package com.htiiot.status.hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;
import java.net.URI;

public class HDFSWriter extends HTWriter {
	
	private static FileSystem fs;
	
	public HDFSWriter(long tID,String host,long time) throws IOException {
		super(tID,host,time);
		Configuration conf = new Configuration();
		if(fs==null) {
			fs = FileSystem.get(URI.create(filePath),conf);
		}
		os = fs.create(new Path(filePath));
	}
	
	public void flush(){
		try {
			((FSDataOutputStream)os).hflush();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}


}
